﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace SCRS.Model;

#nullable disable
[Table("SYS_ACCOUNT")]
public class Account
{
    // ,密码,角色,人脸识别编码
    /// <summary>
    /// 账号ID
    /// </summary>
    // 数据库列名
    [Column("ID")] 
    // 自增主键
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    // 主键
    [Key]
    // 添加字段注释
    [Comment("账号ID")]
    public int Id { get; set; }
    /// <summary>
    /// 姓名
    /// </summary>
    [Column("NAME")]
    [Required] // 非空
    [Comment("姓名")]
    [StringLength(64)]
    public string Name { get; set; }
    /// <summary>
    /// 用户名
    /// </summary>
    [Required]
    [Column("USERNAME")]
    [StringLength(64)]
    [Comment("用户名")]
    public string Username { get; set; }
    /// <summary>
    /// 密码
    /// </summary>
    [Required]
    [Column("PASSWORD",TypeName = "Char")]
    // 长度固定为32
    [StringLength(32)]
    [Comment("密码")]
    public string Password { get; set; }
    /// <summary>
    /// 角色(使用JSON存储,存储的是角色名称,如:["admin","cashier"])
    /// </summary>
    [Required]
    // 类型设置为JSON
    [Column("ROLE",TypeName = "json")]
    [Comment("角色")]
    public string Role { get; set; }
    /// <summary>
    /// 人脸识别编码,使用JSON存储
    /// </summary>
    [Column("FACE_CODE", TypeName = "json")]
    [Comment("人脸识别编码")]
    // 可空
    public string? FaceCode { get; set; }
}